package com.lupan.tomcatStudy.mongodb.districtToBounds;


import com.timanetworks.foundation.common.util.HttpUtil;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

/**
 * 说明：
 *
 * @author lupan
 * @version 2016/4/27
 */
public class Main {

    public static void main(String[] args) {

        String servicesRootUrl = "http://fotondev.timanetwork.com/dev/tm/";
        String securityKey = "2d3e04538ce7ec0a4b21851747eda121";
        String appKey = "3917230828";
        String interfaceUrl = "common-data/commonDataInternal/getProvinceList";
        String url = servicesRootUrl + interfaceUrl;
        Map<String, String> signParams = new HashMap<String, String>();
        signParams.put("appkey", appKey);

        System.out.println(url + "?sign=" + HttpUtil.sign(interfaceUrl, signParams, securityKey) + "&appkey=" + appKey );
        String response = HttpUtil.get(url + "?sign=" + HttpUtil.sign(interfaceUrl, signParams, securityKey) + "&appkey=" + appKey );
        System.out.println(response);

        signParams.put("provinceName","四川省");
        String interfaceUrl2 = "common-data/commonDataInternal/getCityList";
        String url2 = servicesRootUrl + interfaceUrl2;
        System.out.println(url2 + "?sign=" + HttpUtil.sign(interfaceUrl2, signParams, securityKey) + "&appkey=" + appKey +"&provinceName=四川省");
        String response2 = null;
        try {
            response2 = HttpUtil.get(url2 + "?sign=" + HttpUtil.sign(interfaceUrl2, signParams, securityKey) + "&appkey=" + appKey + "&provinceName=" + URLEncoder.encode("四川省", "utf-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        System.out.println(response2);

//        ConvertUtil.convert("成都2",Constant.LEAVE_CITY);
    }
}
